package model;

import java.sql.*;
import java.util.List;

import myBeans.LoginInfo;
import myBeans.MenuInfo;
import myBeans.UserInfo;

public class Repository {
    private Connection conn;
    
	public Repository(Connection conn){
		this.conn = conn;
	}
	
	public boolean Login(LoginInfo LoginBean) {
		try
		{
			Statement stmt = conn.createStatement();
			String sql = "SELECT UserID, Password";
			sql += " FROM tbuser";
			sql += " Where UserID='" + LoginBean.getUserId() + "' and password='" + LoginBean.getPassword() + "'";
			
			ResultSet rs = stmt.executeQuery(sql);
			
			if(rs.next()){	//if user and password is valid.
				return true;				
			}
			else{	//0 row = user and password is not valid
				return false;
			}
			
		
		}
		catch(SQLException ex)
		{
			ex.printStackTrace();
		}
		
		return false;	//default return false

	}
}
